package com.yuhs.zixing.study.design.pattern.dp002.create.c003.prototype.p001;

import lombok.SneakyThrows;

/**
 * @description:
 * @author: yuhs
 * @date: 2022/4/25 9:53 PM
 */
public class Client {
    @SneakyThrows
    public static void main(String[] args) {
        System.out.println("原型模式完成对象的创建");
        Sheep001 sheep = new Sheep001("tom", "白色", 1);
        sheep.friend = new Sheep001("jock", "黑色", 1);
        // 克隆
        Sheep001 sheep2 = (Sheep001) sheep.clone();
        System.out.println("sheep2 = " + sheep2 + " sheep2.friend = " + sheep2.friend.hashCode());
        // 克隆
        Sheep001 sheep3 = (Sheep001) sheep.clone();
        System.out.println("sheep3 = " + sheep3);
        // 克隆
        Sheep001 sheep4 = (Sheep001) sheep.clone();
        System.out.println("sheep4 = " + sheep4);

    }
}
